package com.toivan.mt.fragment;

import android.os.Bundle;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.hwangjr.rxbus.RxBus;
import com.shizhefei.fragment.LazyFragment;
import com.toivan.mt.R;
import com.toivan.mt.adapter.MtQuickBeautyAdapter;
import com.toivan.mt.model.MtQuickBeauty;
import com.toivan.mt.model.RxBusAction;
import com.toivan.mt.utils.MtSharedPreferences;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 一键美颜的面板
 */
public class MtQuickBeautyFragment extends LazyFragment {

    private final List<MtQuickBeauty> quickBeautyList = new ArrayList<>();

    @Override
    protected void onCreateViewLazy(Bundle savedInstanceState) {
        super.onCreateViewLazy(savedInstanceState);
        setContentView(R.layout.fragment_recyclerview);
        quickBeautyList.clear();
        quickBeautyList.addAll(Arrays.asList(MtQuickBeauty.values()));

        RecyclerView quickBeautyRV = (RecyclerView) findViewById(R.id.recyclerView);
        MtQuickBeautyAdapter adapter = new MtQuickBeautyAdapter(quickBeautyList, MtSharedPreferences.getInstance().getQuickBeautyPosition());
        quickBeautyRV.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
        quickBeautyRV.setAdapter(adapter);
        RxBus.get().post(
            RxBusAction.ACTION_QUICK_BEAUTY_SELECTION,
            quickBeautyList
                .get(MtSharedPreferences.getInstance().getQuickBeautyPosition())
                .getQuickBeautyDefault());
    }

}
